package com.shanks.framework.mq.common.util;

/**
 * MQ上下文,传递线程消息
 */
public class MQContext {
    private static ThreadLocal<MQErrorInfo> mqThreadLocal = new ThreadLocal();

    public static MQErrorInfo getErroInfo() {
        return mqThreadLocal.get();
    }

    public static void setErrorInfo(MQErrorInfo mqErrorInfo) {
        mqThreadLocal.set(mqErrorInfo);
    }

    public static void remove() {
        mqThreadLocal.remove();
    }

    /**
     * 错误信息
     */
    public static class MQErrorInfo {
        /**
         * 错误信息
         */
        private String errorMsg;

        /**
         * 具体异常
         */
        private Exception exception;

        public String getErrorMsg() {
            return errorMsg;
        }

        public void setErrorMsg(String errorMsg) {
            this.errorMsg = errorMsg;
        }

        public Exception getException() {
            return exception;
        }

        public void setException(Exception exception) {
            this.exception = exception;
        }
    }

}
